let express = require('express')
let router = express.Router()
router.get('/', async (req, res, next) => {
    // 处理列表业务
    // 整理参数
    let { _limit, _page, _q, _sort } = req.query
    let collectionName = 'goods'
    try {
        let result = await req.mgdb.findList({ collectionName, _limit, _page, _q, _sort })
        res.send(result)
    } catch (e) {
        res.send(e)
    }
})
router.get('/:id', async (req, res, next) => {
    // 处理详情业务
    let collectionName = 'goods'
    let _id = req.params.id
    try {
        let result = await req.mgdb.findDetail({ collectionName, _id })
        res.send(result)
    } catch (e) {
        console.log(e)
        res.send(e)
    }
})
module.exports = router;